package com.lanou.beautifulwardrobe.Home;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lanou.beautifulwardrobe.Home.Adapter.DetailViewPagerAdapter;
import com.lanou.beautifulwardrobe.Home.Adapter.ProductDetailAdapter;
import com.lanou.beautifulwardrobe.R;

/**
 * Created by dllo on 15/11/3.
 */
public class DetailFragment extends Fragment {
    private RecyclerView recyclerView;
    private ProductDetailAdapter adapter;
    private GridLayoutManager manager;
    private static DetailFragment fragment;
    public static DetailFragment getInstance(){
        if(fragment==null){
            fragment=new DetailFragment();
        }
        return  fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v=inflater.inflate(R.layout.home_product_detail,null);
        return v;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        recyclerView= (RecyclerView) view.findViewById(R.id.detailRecyclerView);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }
    private void initView(){
        adapter=ProductDetailAdapter.getInstance();
        manager=new GridLayoutManager(getActivity(),1);
        recyclerView.setLayoutManager(manager);
        recyclerView.setAdapter(adapter);
    }
}
